      SUBROUTINE TABENT(IPASS)
C! Enter data into tables
      INCLUDE 'params.h'
      INCLUDE 'tables.h'
      INCLUDE 'floppy.h'
      INCLUDE 'lunits.h'
      INTEGER SEARCH
      EXTERNAL SEARCH
      CHARACTER*(LCDOIF) CMNT,CDOIF
C
      IF(IPASS.NE.1) GOTO 100
      IF(NPROC+NENT.GT.MAXPRO) GOTO 900
      IF(NCOMM+NCOM.GT.MAXCOM) GOTO 910
      DO 10 IN=1,NENT
        PROCED_NAME(NPROC+IN) = CALLER(IN)
        CMNT = '      '
        IF(LENOCC(CMMNT).NE.0) THEN
          CMNT = ' '
          DO 55 IC=1,LENOCC(CMMNT)
            IF(CMMNT(IC:IC).NE.' ') THEN
              IF(IC.LT.LENOCC(CMMNT)) CMNT = CMMNT(IC:)
              GOTO 56
            ENDIF
   55     CONTINUE
   56     CONTINUE
        ENDIF
        PROCED_DESCRIP(NPROC+IN) = CMNT
C
C loop over common block names
C
        DO 20 IC=1,NCOM
          DO 21 ICO=1,NCOMM
            IF(COMMON_NAME(ICO).EQ.CNAMES(IC)) THEN
              COMMON_USED(NPROC+IN,ICO) = 'Y'
              IF(UNUSED(IC).EQ.'!')
     &            COMMON_USED(NPROC+IN,ICO) = 'N'
              GOTO 22
            ENDIF
   21     CONTINUE
          NCOMM = NCOMM + 1
          COMMON_NAME(NCOMM) = CNAMES(IC)
          COMMON_USED(NPROC+IN,NCOMM) = 'Y'
          IF(UNUSED(IC).EQ.'!')
     &       COMMON_USED(NPROC+IN,NCOMM) = 'N'
   20   CONTINUE
   22   PROCED_NCALLS(NPROC+IN) = KALL
        DO 50 ICL=1,KALL
C
C compose doif string
C
          CDOIF(:) = ' '
          ILDO = MIN(KALLDO(ICL),LCDOIF)
          DO 30 IDO=1,ILDO
            CDOIF(IDO:IDO) = '('
   30     CONTINUE
          ILIF = MIN(LCDOIF-ILDO,KALLIF(ICL))
          DO 31 IIF=1,ILIF
            CDOIF(ILDO+IIF:ILDO+IIF) = '?'
   31     CONTINUE
          PROCED_DOIF(NPROC+IN,ICL) = CDOIF
   50   CONTINUE
   10 CONTINUE
      NPROC = NPROC + NENT
      RETURN
C
C second pass for external names
C
  100 CONTINUE
      DO 110 IN=1,NENT
        IF(KALL.LE.0) GOTO 110
        IPNAM = SEARCH(CALLER(IN))
        DO 120 IC=1,KALL
          IPNAM2 = SEARCH(CALLED(IC))
          IF(IPNAM2.EQ.0) THEN
            NPROC = NPROC + 1
            IPNAM2 = NPROC
            PROCED_NAME(NPROC) = CALLED(IC)
            PROCED_DESCRIP(NPROC) = 'External'
            PROCED_EXTERN(NPROC) = .TRUE.
            PROCED_NCALLS(NPROC) = 0
            PROCED_NCALLEDBY(NPROC) = 0
          ENDIF
          PROCED_CALLS(IPNAM,IC) = IPNAM2
          NCALLEDBY = PROCED_NCALLEDBY(IPNAM2) + 1
          PROCED_NCALLEDBY(IPNAM2) = NCALLEDBY
  120   CONTINUE
  110 CONTINUE
      RETURN
  900 WRITE(LOUT,'(A)') ' TABENT : MAXIMUM NO. OF PROCEDURES EXCEEDED'
      STOP 2
  910 WRITE(LOUT,'(A)') ' TABENT : MAXIMUM NO. OF COMMONS EXCEEDED'
      STOP 3
      END
